package ooday03homework;

public class RefArrayDemo {
    public static void main(String[] args) {
        /*
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小白", 2, "白色");
        dogs[1] = new Dog("小黑", 3, "黑色");
        dogs[2] = new Dog("小黄", 2, "黄色");
        dogs[0].lookHome();dogs[1].eat();dogs[2].drink();dogs[0].swim();
        for (Dog i : dogs) {
            System.out.println(i.name);
            System.out.println(i.age);
            System.out.println(i.color);
        }

        Fish[] fish = new Fish[2];
        fish[0] = new Fish("小鱼", 1, "灰色");
        fish[1] = new Fish("大鱼", 3, "红色");
        fish[0].swim();fish[1].eat();fish[0].drink();
        for (Fish j : fish) {
            System.out.println(j.age);
            System.out.println(j.name);
            System.out.println(j.color);
        }


        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("小鸡", 1, "红色");
        chicks[1] = new Chick("大公鸡", 3, "金色");
        chicks[0].drink();chicks[1].eat();chicks[0].layEggs();
        for (Chick k : chicks) {
            System.out.println(k.age);
            System.out.println(k.name);
            System.out.println(k.color);
        }
    }

         */
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑", 2, "黑色");
        dogs[1] = new Dog("小黄", 2, "黄色");
        dogs[2] = new Dog("小灰", 3, "灰色");
        dogs[0].swim();dogs[1].drink();dogs[2].eat();dogs[1].lookHome();
        for (Dog dog : dogs) {
            System.out.println(dog.age);
            System.out.println(dog.color);
            System.out.println(dog.name);
        }

        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("小鸡", 1, "黄色");
        chicks[1] = new Chick("大鸡", 3, "红色");
        chicks[0].layEggs();chicks[1].drink();chicks[0].eat();
        for (Chick chick : chicks) {
            System.out.println(chick.color);
            System.out.println(chick.name);
            System.out.println(chick.age);
        }

        Fish[] fishes = new Fish[2];
        fishes[0] = new Fish("小鱼", 1, "白色");
        fishes[1] = new Fish("大鱼", 2, "金色");
        fishes[0].drink();fishes[1].swim();fishes[0].eat();
        for (Fish fish : fishes) {
            System.out.println(fish.color);
            System.out.println(fish.name);
            System.out.println(fish.age);
        }
    }
}